﻿#region license
// CopyRight (c) 2009-2010 HangJing Teconology. All Rights Reserved.
// Function :礼品信息详细
// Created by tuhui at 2010-6-24 16:28:14.
// E-Mail: tuhui@ihangjing.com
#endregion
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

using Hangjing.SQLServerDAL;
using Hangjing.Model;
using Hangjing.Common;

public partial class qy_55tuan_Admin_Deliverotherinfo : System.Web.UI.Page
{
    Deliver dal = new Deliver();
    deliverInformation dalinfo = new deliverInformation();

    protected void Page_Load(object sender, EventArgs e)
    {
        ValidatorSet validator = new ValidatorSet("Admin");
        validator.SetValidator();
        if (!Page.IsPostBack)
        {
            int tid = HjNetHelper.GetQueryInt("tid", 0);
            //控件绑定内容
            DeliverInfo deliver = dal.GetModel(tid);
            if (deliver != null)
            {
                diagram_tab_orders.HRef = "DeliverDetail.aspx?id=" + tid + "&cityid=" + deliver.Inve1;

                deliverInformationInfo info = dalinfo.GetModelByDeliverID(tid);
                if (info != null)
                {
                    tbaddress.Text = info.address;
                    tbMarriage.Text = info.Marriage;
                    tbhomeaddress.Text = info.homeaddress;
                    tbNation.Text = info.Nation;
                    tbQQ.Text = info.QQ;
                    tbEducation.Text = info.Education;
                    tbEmergency.Text = info.Emergency;
                    tbEmergencyphone.Text = info.Emergencyphone;
                    tbEntrytime.Text = info.Entrytime;
                    tbSalarycard.Text = info.Salarycard;
                    tbBank.Text = info.Bank;
                    tbworkexperience.Text = info.workexperience;
                    tbReward.Text = info.Reward;
                    tbComplaint.Text = info.Complaint;
                    tbage.Text = info.age.ToString();
                    tbremark.Text = info.remark;
                    tbrevevar1.Text = info.revevar1;

                    if (!string.IsNullOrEmpty(info.revevar2))
                    {
                        if (info.revevar2.Length > 256)
                        {
                            ImgUrl.Src = info.revevar2;
                        }
                        else
                        {
                            ImgUrl.Src = WebUtility.ShowPic(info.revevar2);
                        }
                    }
                    this.ImgUrl1.Value = info.revevar2;
                }
            }

        }
    }

    protected void btSave_Click(object sender, EventArgs e)
    {
        int tid = HjNetHelper.GetQueryInt("tid", 0);
        deliverInformationInfo info = dalinfo.GetModelByDeliverID(tid);
        if (info == null)
        {
            info = new deliverInformationInfo();
        }
        info.deliverid = tid;
        info.address = WebUtility.InputText(tbaddress.Text);
        info.Marriage = WebUtility.InputText(tbMarriage.Text);
        info.homeaddress = WebUtility.InputText(tbhomeaddress.Text);
        info.Nation = WebUtility.InputText(tbNation.Text);
        info.QQ = WebUtility.InputText(tbQQ.Text);
        info.Education = WebUtility.InputText(tbEducation.Text);
        info.Emergency = WebUtility.InputText(tbEmergency.Text);
        info.Emergencyphone = WebUtility.InputText(tbEmergencyphone.Text);
        info.Entrytime = WebUtility.InputText(tbEntrytime.Text);
        info.Salarycard = WebUtility.InputText(tbSalarycard.Text);
        info.Bank = WebUtility.InputText(tbBank.Text);
        info.workexperience = WebUtility.InputText(tbworkexperience.Text);
        info.Reward = WebUtility.InputText(tbReward.Text);
        info.Complaint = WebUtility.InputText(tbComplaint.Text);
        info.Bond = 0;
        info.age = WebUtility.InputText(tbage.Text,true);
        info.reveint1 = 0;
        info.reveint2 = 0;
        info.reveint3 = "0";
        info.revevar1 = WebUtility.InputText(tbrevevar1.Text);
        info.revevar3 = "";
        info.revedate1 = Convert.ToDateTime("1970-1-1");
        info.remark = WebUtility.InputText(tbremark.Text);
        info.revevar2 = ImgUrl1.Value;

        //判断权限
        int _rs = WebUtility.checkOperator(2);
        if (_rs == 0)
        {
            AlertScript.RegScript(this.Page, this.UpdatePanel1, "alert('无操作权限','success','true',5);");
            return;
        }
        if (dalinfo.Add(info) > 0)
        {
            AlertScript.RegScript(this.Page, UpdatePanel1, "showMessage('修改成功','success','true',5);");

            ImgUrl.Src = WebUtility.ShowPic(info.revevar2);
        }
        else
        {
            AlertScript.RegScript(this.Page, this.UpdatePanel1, "showMessage('修改失败','error','true',5);");
        }




    }
}
